<!DOCTYPE HTML>
<html>
<head>
    <title>房屋详情</title>
    <% include common/meta.ejs %>
    <% include common/public.ejs %>
</head>
<body ontouchstart="">
<div class="swiper-container" data-space-between='10'>
    <div class="swiper-wrapper">
        <% if(data.aimage) { %>
        <div class="swiper-slide">
            <img src="<%= '/yams-upload'+ data.aimage %>" />

        </div>
        <% } %>
        <% if(data.bimage) { %>
        <div class="swiper-slide">
            <img src="<%= '/yams-upload'+ data.bimage %>" />
        </div>
        <% } %>
        <% if(data.cimage) { %>
        <div class="swiper-slide">
            <img src="<%= '/yams-upload'+ data.cimage %>" />
        </div>
        <% } %>
        <% if(data.dimage) { %>
        <div class="swiper-slide">
            <img src="<%= '/yams-upload'+ data.dimage %>" />
        </div>
        <% } %>
        <% if(data.eimage) { %>
        <div class="swiper-slide">
            <img src="<%= '/yams-upload'+ data.eimage %>" />
        </div>
        <% } %>
        <% if(data.fimage) { %>
        <div class="swiper-slide">
            <img src="<%= '/yams-upload'+ data.fimage %>" />
        </div>
        <% } %>
        <% if(data.gimage) { %>
        <div class="swiper-slide">
            <img src="<%= '/yams-upload'+ data.gimage %>" />
        </div>
        <% } %>
        <% if(data.himage) { %>
        <div class="swiper-slide">
            <img src="<%= '/yams-upload'+ data.himage %>" />
        </div>
        <% } %>
        <% if(data.iimage) { %>
        <div class="swiper-slide">
            <img src="<%= '/yams-upload'+ data.iimage %>" />
        </div>
        <% } %>
        <% if(data.jimage) { %>
        <div class="swiper-slide">
            <img src="<%= '/yams-upload'+ data.jimage %>" />
        </div>
        <% } %>
        <% if(data.kimage) { %>
        <div class="swiper-slide">
            <img src="<%= '/yams-upload'+ data.kimage %>" />
        </div>
        <% } %>
        <% if(data.limage) { %>
        <div class="swiper-slide">
            <img src="<%= '/yams-upload'+ data.limage %>" />
        </div>
        <% } %>
    </div>
    <div class="swiper-pagination"></div>
</div>

<div class="weui_panel weui_panel_access">
    <div class="weui_panel_bd">
        <div class="weui_media_box weui_media_text" style="padding: 1rem;">
            <p style="font-weight:700;font-size: 0.7rem;color: #141414;margin-bottom: 0.2rem"><%= data.shortDesc %></p>
            <p class="weui_media_desc"><%= data.name %></p>
        </div>
        <div class="weui-row">
            <div class="weui-col-33">
                <p>租金</p>
                <p class="x-fs-080"><%= data.monthly %></p>
            </div>
            <div class="weui-col-33">
                <p>房型</p>
                <p class="x-fs-080"><%= data.houseTypeName %></p>
            </div>
            <div class="weui-col-33">
                <p>面积</p>
                <p class="x-fs-080"><%= data.area %>㎡</p>
            </div>
        </div>
    </div>
</div>

<div class="weui_cells_title">房屋详情</div>
<div class="weui_cells" style="font-size: 0.7rem;">
    <div class="weui_cell">
        <div class="weui_cell_bd">
            <p>区域：</p>
        </div>
        <div class="weui_cell_ft">
            <%= data.apartmentName %>
        </div>
    </div>
    <div class="weui_cell">
        <div class="weui_cell_bd" style="width: 70em">
            <p>地址：<%= data.myAddress %></p>
        </div>
        <div class="weui_cell_ft" id="milkMap">
            <img src="<%= global.config.publicPath %>/page/images/mapSet.png" style="width: 20%;height: 20%">
        </div>
    </div>


    <div class="weui_cell">
        <div class="weui_cell_bd ">
            <p>楼层：</p>
        </div>
        <div class="weui_cell_ft">
            <%= data.floor %>层
        </div>
    </div>
    <div class="weui_cell">
        <div class="weui_cell_bd ">
            <p>楼主：</p>
        </div>
        <div class="weui_cell_ft">
            <%= data.properties.manager.name %>(<%= data.properties.manager.phone%>)
        </div>
    </div>

    <div class="weui_cell" style="position: relative">
        <div class="weui_cell_bd ">
            <p>床铺信息：</p>
        </div>
        <div class="weui_cell_ft" style="position: absolute;margin: 13px 68px;">
            <%if(data.beds.length<=0){%>
                暂无信息
            <%}
            else{
                for(let i=0;i<data.beds.length;i++){
                    let eachBed=data.beds[i],__type;
                    if(eachBed && eachBed.bedType){
                        if(eachBed.bedType ==	'BED01'){
                            __type='单人床';
                        }else{
                            __type='双人床';
                        }
                    }
                    %>
                    <%="类型:"+(__type!=null?__type:'无')+"("+(eachBed.bedLength!=null?eachBed.bedLength:'无')+" x "+(eachBed.bedWidth!=null?eachBed.bedWidth:'无')+")"%><br/>
            <%
                }
            }
            %>
        </div>
    </div>

    <div class="weui_cells" style="font-size: 0.7rem;padding: 10px">
        <div>
            <%- data.uedit %>
        </div>
    </div>
</div>
<div class="bottomBar">
    <a class="weui_btn weui_btn_primary" id="order">预约看房</a>
</div>
<% include common/footer.ejs %>
<script src="<%= global.config.cdn %>/Swiper/3.3.1/js/swiper.jquery.<%= global.config.mode %>js"></script>
<script>
    $(".swiper-container").swiper({
        loop: true,
        autoplay: 3000
    });
    let _userId='<%= userData.id %>';
    let s=  '<%= data.id%>';
    $("#order").click(function () {
        var flag=true;
        Dolphin.ajax({
            url:CTX+'/api/00923c89a610415d8e70b1b4f2380e75',
            type:'post',
            data:{},
            forceUrl:'true',
            onSuccess:function (reDate) {
                for(var i=0;i<reDate.rows.length;i++){
                    if(s==reDate.rows[i].house.id && _userId==reDate.rows[i].userId){
                        flag=false;
                        alert("不能重复预订");
                    }
                }
                if(flag){
                    location.href="houseReserved?houseId="+s;
                }

            }
        });
    });

</script>
<script src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js" type="text/javascript"></script>
<script type="text/javascript">
    var apt = JSON.parse('<%= JSON.stringify(data.apartment); %>'.replace(/&#34;/g, '"') || "{}");
    if(apt != null){
        var zuobiao=apt.lngAndLat;
        var a = zuobiao.split(",");
        var lat=Number(a[0]),
            lng=Number(a[1]);
        wx.config({
            debug: false,
            appId: "<%= data.appId %>", // 必填，公众号的唯一标识
            timestamp: "<%= data.timestamp %>",
            nonceStr: "<%= data.nonceStr %>",
            signature: "<%= data.signature %>",
            jsApiList: [  // 必填，需要使用的JS接口列表
                'getLocation',
                'openLocation'
            ]
        });
        wx.ready(function(){
            $("#milkMap").click(function () {
                wx.openLocation({
                    latitude: lng, // 纬度，浮点数，范围为90 ~ -90
                    longitude: lat, // 经度，浮点数，范围为180 ~ -180。
                    name: '<%= data.myAddress %>', // 位置名
                    address: '<%= data.myAddress %>', // 地址详情说明
                    scale: 10, // 地图缩放级别,整形值,范围从1~28。默认为最大
                    infoUrl: '' // 在查看位置界面底部显示的超链接,可点击跳转
                });
            });
        });

        wx.error(function(res) {
            // config信息验证失败会执行error函数，如签名过期导致验证失败，具体错误信息可以打开config的debug模式查看，也可以在返回的res参数中查看，对于SPA可以在这里更新签名。
        });
    }

</script>
</body>
</html>